#include "Menu.h"

Menu::Menu(void)
{
}

Menu::~Menu(void)
{
}


void Menu::createMenu(IDirect3DDevice9* m_pD3DDevice, DirectInput* input)
{
	D3DXCreateSprite(m_pD3DDevice,&m_Sprite);

#pragma region Buttons
#pragma region Main Buttons
	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestExitButton.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_QuitButton);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestCreditsButton.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_CreditButton);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestOptionsButton.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_OptionsButton);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestPlayGameButton.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_PlayButton);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestTitleCommand.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_TitleButton);
#pragma endregion

#pragma region Options
	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestFullScreen.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_FullScreenButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestWindowed.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_WindowedButtonTexture);
#pragma endregion

#pragma region Character Select
	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestBrains.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_BrainsButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestBrawn.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_BrawnsButtonTexture);
#pragma endregion

#pragma region Level Select
	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestBlank.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_BlankButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestGo.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_GoButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestZero.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_ZeroButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestOne.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_OneButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestTwo.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_TwoButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestThree.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_ThreeButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestFour.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_FourButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestFive.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_FiveButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestSix.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_SixButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestSeven.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_SevenButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestEight.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_EightButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestNine.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_NineButtonTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestEntry.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),
		NULL,
		NULL,
		&m_TextBoxTexture);
#pragma endregion
#pragma endregion
#pragma region Backgrounds
	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestTitleScreen.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_TitleScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestOptions.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_OptionsScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestCredits.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_CreditsScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestCharacterSelect.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_CharacterSelectScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestLevelSelect.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_LevelSelectScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestPaused.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_PausedScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestDeath.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_DeathScreenTexture);

	D3DXCreateTextureFromFileEx(m_pD3DDevice,
		L"TestWin.png",
		0,
		0,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,183,183),
		NULL,
		NULL,
		&m_WinScreenTexture);
#pragma endregion


	inputs = input;
	levelCode = "----";
	currCodeValue = 0;

	currState = TITLE;
	selection = PLAYBUTTON;
}


void Menu::destroyMenu()
{
	SAFE_RELEASE(m_TextBoxTexture);//texture 30
	SAFE_RELEASE(m_BlankButtonTexture);//texture 29
	SAFE_RELEASE(m_GoButtonTexture);//texture 28
	SAFE_RELEASE(m_ZeroButtonTexture);//texture 27
	SAFE_RELEASE(m_NineButtonTexture);//texture 26
	SAFE_RELEASE(m_EightButtonTexture);//texture 25
	SAFE_RELEASE(m_SevenButtonTexture);//texture 24
	SAFE_RELEASE(m_SixButtonTexture);//texture 23
	SAFE_RELEASE(m_FiveButtonTexture);//texture 22
	SAFE_RELEASE(m_FourButtonTexture);//texture 21
	SAFE_RELEASE(m_ThreeButtonTexture);//texture 20
	SAFE_RELEASE(m_TwoButtonTexture);//texture 19
	SAFE_RELEASE(m_OneButtonTexture);//texture 18
	SAFE_RELEASE(m_BrainsButtonTexture);//texture 17
	SAFE_RELEASE(m_BrawnsButtonTexture);//texture 16
	SAFE_RELEASE(m_FullScreenButtonTexture);//texture 15
	SAFE_RELEASE(m_WindowedButtonTexture);//texture 14
	SAFE_RELEASE(m_WinScreenTexture);//texture 13
	SAFE_RELEASE(m_DeathScreenTexture);//texture 12
	SAFE_RELEASE(m_PausedScreenTexture);//texture 11
	SAFE_RELEASE(m_LevelSelectScreenTexture);//texture 10
	SAFE_RELEASE(m_CharacterSelectScreenTexture);//texture 9
	SAFE_RELEASE(m_CreditsScreenTexture);//texture 8
	SAFE_RELEASE(m_OptionsScreenTexture);//texture 7
	SAFE_RELEASE(m_TitleButton);//texture 6
	SAFE_RELEASE(m_CreditButton);//texture 5
	SAFE_RELEASE(m_OptionsButton);//texture 4
	SAFE_RELEASE(m_PlayButton);//texture 3
	SAFE_RELEASE(m_QuitButton);//texture 2
	SAFE_RELEASE(m_TitleScreenTexture);//texture 1
	SAFE_RELEASE(m_Sprite);//sprite object
}


States Menu::displayMenu(States state, States currentState)
{
	States temp = LEVELONE;
	inputs->detect_input();

	m_Sprite->Begin(D3DXSPRITE_ALPHABLEND);

	clearMatrices();

	switch(state)
	{
	case TITLE:
		drawTitleScreen();
		temp = titleInput();
		break;
	case MAIN:
		//main menu
		drawMainMenu();
		temp = mainMenuInput();
		break;
	case OPTIONS:
		//options menu
		drawOptionsScreen();
		temp = optionsInput();
		break;
	case CREDITS:
		//credits menu
		drawCreditsScreen();
		temp = creditsInput();
		break;
	case CHARACTERSELECT:
		//Character Selection Screen.
		drawCharacterSelect();
		temp = characterSelectInput();
		break;
	case LEVELSELECT:
		//Level selection screen
		drawLevelSelect();
		temp = levelSelectInput();
		break;
	case PAUSED:
		//paused screen
		drawPausedScreen();
		temp = pausedInput(currentState);
		break;
	case DEATH:
		//death screen
		drawDeathScreen();
		temp = deathInput();
		break;
	case WIN:
		//win screen
		drawWinScreen();
		temp = winInput();
		break;
	default:
		//game is playing

		break;

	}

	m_Sprite->End();
	return temp;
}

void Menu::onLostDevice()
{
	m_Sprite->OnLostDevice();
}

void Menu::onResetDevice()
{
	m_Sprite->OnResetDevice();
}

//calls the necessary sprite information needed to draw the title screen
void Menu::drawTitleScreen()
{
	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_TitleScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));

	clearMatrices();
	m_Sprite->SetTransform(&worldMat);
	m_Sprite->Draw(m_TitleButton,0,0, &D3DXVECTOR3(300,500,0),D3DCOLOR_XRGB(255,255,255));
}

//calls the necessary sprite information needed to draw the Main Menu
void Menu::drawMainMenu()
{
	D3DCOLOR selected = D3DCOLOR_XRGB(128,128,128);

	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);
	m_Sprite->Draw(m_TitleScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));

	clearMatrices();

	D3DXMatrixTranslation(&transMat,200,392,0);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);
	if(selection == PLAYBUTTON)
	{
		m_Sprite->Draw(m_PlayButton,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_PlayButton,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat,200,488,0);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == OPTIONSBUTTON)
	{
		m_Sprite->Draw(m_OptionsButton,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_OptionsButton,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat,600,392,0);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == CREDITSBUTTON)
	{
		m_Sprite->Draw(m_CreditButton,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_CreditButton,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat,600,488,0);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);
	if(selection == QUITBUTTON)
	{
		m_Sprite->Draw(m_QuitButton,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_QuitButton,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}
}

//calls the necessary sprite information needed to draw the Options Screen
void Menu::drawOptionsScreen()
{
	D3DCOLOR selected = D3DCOLOR_XRGB(128,128,128);

	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_OptionsScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));

	clearMatrices();

	D3DXMatrixScaling(&scaMat, 2.0f,2.0f,1.0f);
	D3DXMatrixTranslation(&transMat, 400.0f, 200.0f,0.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == WINDOWEDBUTTON)
	{
		m_Sprite->Draw(m_WindowedButtonTexture,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_WindowedButtonTexture,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixScaling(&scaMat, 2.0f, 2.0f,1.0f);
	D3DXMatrixTranslation(&transMat, 400.0f, 400.0f,0.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == FULLSCREENBUTTON)
	{
		m_Sprite->Draw(m_FullScreenButtonTexture,0,&D3DXVECTOR3(64,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_FullScreenButtonTexture,0,&D3DXVECTOR3(64,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}
}

//calls the necessary sprite information needed to draw the Credits Screen
void Menu::drawCreditsScreen()
{
	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_CreditsScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));
}

//calls the necessary sprite information needed to draw the Character Select Screen
void Menu::drawCharacterSelect()
{
	D3DCOLOR selected = D3DCOLOR_XRGB(128,128,128);

	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_CharacterSelectScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 210.0f, 330.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 3.0f,2.0f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == BRAWNS)
	{
		m_Sprite->Draw(m_BrawnsButtonTexture,0, &D3DXVECTOR3(64,128,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_BrawnsButtonTexture,0, &D3DXVECTOR3(64,128,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 600.0f, 330.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 3.0f,2.0f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == BRAINS)
	{
		m_Sprite->Draw(m_BrainsButtonTexture,0, &D3DXVECTOR3(64,128,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_BrainsButtonTexture,0, &D3DXVECTOR3(64,128,0),0,D3DCOLOR_XRGB(255,255,255));
	}
}

//calls the necessary sprite information needed to draw the Level Select Screen
void Menu::drawLevelSelect()
{
	D3DCOLOR selected = D3DCOLOR_XRGB(0,0,0);

	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_LevelSelectScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 400.0f, 135.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_TextBoxTexture,0,&D3DXVECTOR3(128,32,0),0,D3DCOLOR_XRGB(255,255,255));

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 260.0f, 235.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == ONE)
	{
		m_Sprite->Draw(m_OneButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_OneButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 420.0f, 235.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == TWO)
	{
		m_Sprite->Draw(m_TwoButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_TwoButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 580.0f, 235.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == THREE)
	{
		m_Sprite->Draw(m_ThreeButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_ThreeButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 260.0f, 320.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == FOUR)
	{
		m_Sprite->Draw(m_FourButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_FourButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 420.0f, 320.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == FIVE)
	{
		m_Sprite->Draw(m_FiveButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_FiveButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 580.0f, 320.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == SIX)
	{
		m_Sprite->Draw(m_SixButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_SixButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 260.0f, 405.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == SEVEN)
	{
		m_Sprite->Draw(m_SevenButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_SevenButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 420.0f, 405.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == EIGHT)
	{
		m_Sprite->Draw(m_EightButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_EightButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 580.0f, 405.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == NINE)
	{
		m_Sprite->Draw(m_NineButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_NineButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 260.0f, 500.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == BLANK)
	{
		m_Sprite->Draw(m_BlankButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_BlankButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 420.0f, 500.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == ZERO)
	{
		m_Sprite->Draw(m_ZeroButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_ZeroButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	clearMatrices();

	D3DXMatrixTranslation(&transMat, 580.0f, 500.0f, 0.0f);
	D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	if(selection == GO)
	{
		m_Sprite->Draw(m_GoButtonTexture,0, &D3DXVECTOR3(32,32,0),0,selected);
	}
	else
	{
		m_Sprite->Draw(m_GoButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
	}

	for(int i = 0; i < 4; ++i)
	{
		clearMatrices();

		D3DXMatrixTranslation(&transMat, (210.0f + (i * 110)), 150.0f, 0.0f);
		D3DXMatrixScaling(&scaMat, 2.0f,1.5f,1.0f);
		worldMat = scaMat * rotMat * transMat;
		m_Sprite->SetTransform(&worldMat);

		switch(levelCode[i])
		{
		case '-':
			m_Sprite->Draw(m_BlankButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '0':
			m_Sprite->Draw(m_ZeroButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '1':
			m_Sprite->Draw(m_OneButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '2':
			m_Sprite->Draw(m_TwoButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '3':
			m_Sprite->Draw(m_ThreeButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '4':
			m_Sprite->Draw(m_FourButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '5':
			m_Sprite->Draw(m_FiveButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '6':
			m_Sprite->Draw(m_SixButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '7':
			m_Sprite->Draw(m_SevenButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '8':
			m_Sprite->Draw(m_EightButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		case '9':
			m_Sprite->Draw(m_NineButtonTexture,0, &D3DXVECTOR3(32,32,0),0,D3DCOLOR_XRGB(255,255,255));
			break;
		default:
			break;
		}
	}

}

//calls the necessary sprite information needed to draw the Paused Screen
void Menu::drawPausedScreen()
{
	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_PausedScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));
}

//calls the necessary sprite information needed to draw the Death Screen
void Menu::drawDeathScreen()
{
	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_DeathScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));
}

//calls the necessary sprite information needed to draw the Win Screen
void Menu::drawWinScreen()
{
	D3DXMatrixScaling(&scaMat, 1.5625f,1.171875f,1.0f);
	worldMat = scaMat * rotMat * transMat;
	m_Sprite->SetTransform(&worldMat);

	m_Sprite->Draw(m_WinScreenTexture,0,0, &D3DXVECTOR3(0,0,0),D3DCOLOR_XRGB(255,255,255));
}

//uses the input so that keys are recognized in the Title State
States Menu::titleInput()
{
	States state = TITLE;
	if(inputs->keyDown(DIK_RETURN))
	{
		if(!keyDown[DIK_RETURN])
		{
			state = MAIN;
			keyDown[DIK_RETURN] = true;
		}
	}
	else
	{
		if(keyDown[DIK_RETURN])
		{
			keyDown[DIK_RETURN] = false;
		}
	}

	return state;
}

//uses the input so that keys are recognized in the Main State
States Menu::mainMenuInput()
{
	States state = MAIN;
	if(inputs->keyDown(DIK_P))
	{
		if(!keyDown[DIK_P])
		{
			state = OPTIONS;
			keyDown[DIK_P] = true;
		}
	}
	else
	{
		if(keyDown[DIK_P])
		{
			keyDown[DIK_P] = false;
		}
	}
	switch(selection)
	{
	case PLAYBUTTON:
		{
			if(inputs->keyDown(DIK_RIGHT))
			{
				if(!keyDown[DIK_RIGHT])
				{
					selection = CREDITSBUTTON;
					keyDown[DIK_RIGHT] = true;
				}
			}
			else if(inputs->keyDown(DIK_DOWN))
			{
				if(!keyDown[DIK_DOWN])
				{
					selection = OPTIONSBUTTON;
					keyDown[DIK_DOWN] = false;
				}
			}
			else if(inputs->keyDown(DIK_RETURN))
			{
				if(!keyDown[DIK_RETURN])
				{
					state = CHARACTERSELECT;
					selection = BRAWNS;
					keyDown[DIK_RETURN] = true;
				}
			}
			else
			{
				if(keyDown[DIK_RETURN])
				{
					keyDown[DIK_RETURN] = false;
				}
				if(keyDown[DIK_DOWN])
				{
					keyDown[DIK_DOWN] = false;
				}
				if(keyDown[DIK_RIGHT])
				{
					keyDown[DIK_RIGHT] = false;
				}
			}

			break;
		}
	case OPTIONSBUTTON:
		{
			if(inputs->keyDown(DIK_UP))
			{
				if(!keyDown[DIK_UP])
				{
					selection = PLAYBUTTON;
					keyDown[DIK_UP] = true;
				}
			}
			else if(inputs->keyDown(DIK_RIGHT))
			{
				if(!keyDown[DIK_RIGHT])
				{
					selection = QUITBUTTON;
					keyDown[DIK_RIGHT] = true;
				}
			}
			else if(inputs->keyDown(DIK_RETURN))
			{
				if(!keyDown[DIK_RETURN])
				{
					state = OPTIONS;
					selection = WINDOWEDBUTTON;
					keyDown[DIK_RETURN] = true;
				}

			}
			else
			{
				if(keyDown[DIK_RETURN])
				{
					keyDown[DIK_RETURN] = false;
				}
				if(keyDown[DIK_RIGHT])
				{
					keyDown[DIK_RIGHT] = false;
				}
				if(keyDown[DIK_UP])
				{
					keyDown[DIK_UP] = false;
				}
			}
			break;
		}
	case CREDITSBUTTON:
		{
			if(inputs->keyDown(DIK_LEFT))
			{
				if(!keyDown[DIK_LEFT])
				{
					selection = PLAYBUTTON;
					keyDown[DIK_LEFT] = true;
				}
			}
			else if(inputs->keyDown(DIK_DOWN))
			{
				if(!keyDown[DIK_DOWN])
				{
					selection = QUITBUTTON;
					keyDown[DIK_DOWN] = true;
				}
			}
			else if(inputs->keyDown(DIK_RETURN))
			{
				if(!keyDown[DIK_RETURN])
				{
					state = CREDITS;
					keyDown[DIK_RETURN] = true;
				}
			}
			else
			{
				if(keyDown[DIK_RETURN])
				{
					keyDown[DIK_RETURN] = false;
				}
				if(keyDown[DIK_DOWN])
				{
					keyDown[DIK_DOWN] = false;
				}
				if(keyDown[DIK_LEFT])
				{
					keyDown[DIK_LEFT] = false;
				}
			}
			break;
		}
	case QUITBUTTON:
		{
			if(inputs->keyDown(DIK_UP))
			{
				if(!keyDown[DIK_UP])
				{
					selection = CREDITSBUTTON;
					keyDown[DIK_UP] = true;
				}
			}
			else if(inputs->keyDown(DIK_LEFT))
			{
				if(!keyDown[DIK_LEFT])
				{
					selection = OPTIONSBUTTON;
					keyDown[DIK_LEFT] = true;
				}
			}
			else if(inputs->keyDown(DIK_RETURN))
			{
				PostQuitMessage(0);
			}
			else
			{
				if(keyDown[DIK_RETURN])
				{
					keyDown[DIK_RETURN] = false;
				}
				if(keyDown[DIK_UP])
				{
					keyDown[DIK_UP] = false;
				}
				if(keyDown[DIK_LEFT])
				{
					keyDown[DIK_LEFT] = false;
				}
			}
			break;
		}
	}
	return state;
}

//uses the input so that keys are recognized in the Options State
States Menu::optionsInput()
{
	States state = OPTIONS;
	if(inputs->keyDown(DIK_P))
	{
		if(!keyDown[DIK_P])
		{
			state = CREDITS;
			keyDown[DIK_P] = true;
		}
	}
	else
	{
		if(keyDown[DIK_P])
		{
			keyDown[DIK_P] = false;
		}
	}
	switch(selection)
	{
	case WINDOWEDBUTTON:
		if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = FULLSCREENBUTTON;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				state = MAIN;
				selection = PLAYBUTTON;
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case FULLSCREENBUTTON:
		if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = WINDOWEDBUTTON;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				state = MAIN;
				selection = PLAYBUTTON;
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;

	}
	return state;
}

//uses the input so that keys are recognized in the Credits State
States Menu::creditsInput()
{
	States state = CREDITS;
	if(inputs->keyDown(DIK_RETURN))
	{
		if(!keyDown[DIK_RETURN])
		{
			state = MAIN;
			keyDown[DIK_RETURN] = true;
		}
	}
	else
	{
		if(keyDown[DIK_RETURN])
		{
			keyDown[DIK_RETURN] = false;
		}
	}
	return state;
}

//uses the input so that keys are recognized in the Character State
States Menu::characterSelectInput()
{
	States state = CHARACTERSELECT;
	if(inputs->keyDown(DIK_P))
	{
		if(!keyDown[DIK_P])
		{
			state = LEVELSELECT;
			keyDown[DIK_P] = true;
		}
	}
	else
	{
		if(keyDown[DIK_P])
		{
			keyDown[DIK_P] = false;
		}
	}
	switch(selection)
	{
	case BRAWNS:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = BRAINS;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				state = LEVELONE;
				chosenCharacter = BRAWNS;
				selection = PLAYBUTTON;
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case BRAINS:
		if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = BRAWNS;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				state = LEVELONE;
				chosenCharacter = BRAINS;
				selection = PLAYBUTTON;
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	}
	return state;
}

//uses the input so that keys are recognized in the Level State
States Menu::levelSelectInput()
{
	States state = LEVELSELECT;
	if(inputs->keyDown(DIK_P))
	{
		if(!keyDown[DIK_P])
		{
			state = LEVELONE;
			keyDown[DIK_P] = true;
		}
	}
	else
	{
		if(keyDown[DIK_P])
		{
			keyDown[DIK_P] = false;
		}
	}

	switch(selection)
	{
	case ONE:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = TWO;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = FOUR;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '1';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case TWO:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = THREE;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = FIVE;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = ONE;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '2';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case THREE:
		if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = SIX;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = TWO;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '3';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case FOUR:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = FIVE;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = SEVEN;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = ONE;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '4';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case FIVE:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = SIX;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = EIGHT;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = FOUR;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = TWO;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '5';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case SIX:
		if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = FIVE;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = NINE;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = THREE;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '6';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case SEVEN:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = EIGHT;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = BLANK;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = FOUR;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '7';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case EIGHT:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = NINE;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = ZERO;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = SEVEN;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = FIVE;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '8';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case NINE:
		if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = EIGHT;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_DOWN))
		{
			if(!keyDown[DIK_DOWN])
			{
				selection = GO;
				keyDown[DIK_DOWN] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = SIX;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '9';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_DOWN])
			{
				keyDown[DIK_DOWN] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case BLANK:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = ZERO;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = SEVEN;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '-';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case ZERO:
		if(inputs->keyDown(DIK_RIGHT))
		{
			if(!keyDown[DIK_RIGHT])
			{
				selection = GO;
				keyDown[DIK_RIGHT] = true;
			}
		}
		else if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = BLANK;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = EIGHT;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				levelCode[currCodeValue] = '0';
				currCodeValue++;
				if(currCodeValue == 4)
				{
					currCodeValue = 0;
				}
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_RIGHT])
			{
				keyDown[DIK_RIGHT] = false;
			}
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	case GO:
		if(inputs->keyDown(DIK_LEFT))
		{
			if(!keyDown[DIK_LEFT])
			{
				selection = ZERO;
				keyDown[DIK_LEFT] = true;
			}
		}
		else if(inputs->keyDown(DIK_UP))
		{
			if(!keyDown[DIK_UP])
			{
				selection = NINE;
				keyDown[DIK_UP] = true;
			}
		}
		else if(inputs->keyDown(DIK_RETURN))
		{
			if(!keyDown[DIK_RETURN])
			{
				state = codeCheck();
				keyDown[DIK_RETURN] = true;
			}
		}
		else
		{
			if(keyDown[DIK_LEFT])
			{
				keyDown[DIK_LEFT] = false;
			}
			if(keyDown[DIK_UP])
			{
				keyDown[DIK_UP] = false;
			}
			if(keyDown[DIK_RETURN])
			{
				keyDown[DIK_RETURN] = false;
			}
		}
		break;
	}
	return state;
}

//uses the input so that keys are recognized in the Paused State
States Menu::pausedInput(States currentState)
{
	States state = PAUSED;
	if(inputs->keyDown(DIK_P))
	{
		if(!keyDown[DIK_P])
		{
			state = currentState;
			keyDown[DIK_P] = true;
		}
	}
	else
	{
		if(keyDown[DIK_P])
		{
			keyDown[DIK_P] = false;
		}
	}
	return state;
}

//uses the input so that keys are recognized in the Death State
States Menu::deathInput()
{
	States state = DEATH;
	if(inputs->keyDown(DIK_RETURN))
	{
		if(!keyDown[DIK_RETURN])
		{
			state = MAIN;
			selection = PLAYBUTTON;
			keyDown[DIK_RETURN] = true;
		}
	}
	else
	{
		if(keyDown[DIK_RETURN])
		{
			keyDown[DIK_RETURN] = false;
		}
	}
	return state;
}

//uses the input so that keys are recognized in the Win State
States Menu::winInput()
{
	States state = WIN;
	if(inputs->keyDown(DIK_RETURN))
	{
		if(!keyDown[DIK_RETURN])
		{
			state = MAIN;
			selection = PLAYBUTTON;
			keyDown[DIK_RETURN] = true;
		}
	}
	else
	{
		if(keyDown[DIK_RETURN])
		{
			keyDown[DIK_RETURN] = false;
		}
	}
	return state;
}

void Menu::clearMatrices()
{
	D3DXMatrixIdentity(&rotMat);
	D3DXMatrixIdentity(&scaMat);
	D3DXMatrixIdentity(&transMat);
	D3DXMatrixIdentity(&worldMat);
}

States Menu::codeCheck()
{
	if(levelCode.compare("1234") == 0)
	{
		return LEVELTHREE;
	}
	else if(levelCode.compare("4567") == 0)
	{
		return LEVELTWO;
	}
	else
	{
		return LEVELONE;
	}
}